#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <strings.h>
#include <unistd.h>

#define BUFF_LEN 1024

const char HELP_DOC[] = \
	"Usage: program size_to_read";
	

int main(int argc, char **argv){
	char filename[] = "./test";
	
	int fd = open(filename, O_RDONLY);
	if (fd == -1){
		perror("Opening failed.");
		exit(-1);
	}
	
	char buff[BUFF_LEN];
	bzero(buff, BUFF_LEN);  //clear the buffer
	read(fd, buff, atoi(argv[1]));
	
	printf("read:\n %s", buff);
	close(fd); 
	
	return 0;
} 


